[create a Namespace]
$ kubectl create namespace mem-example

[create the 1st Pod]
$ kubectl apply -f Pod_1.yaml --namespace=mem-example
$ kubectl apply -f https://k8s.io/examples/pods/resource/memory-request-limit.yaml --namespace=mem-example

[verify that the Pod Container is running]
$ kubectl get pod memory-demo --namespace=mem-example

[view detailed information about the Pod]
$ kubectl get pod memory-demo --output=yaml --namespace=mem-example
..........
..........
resources:
  requests:
    memory: 100Mi
  limits:
    memory: 200Mi
..........
..........

● The output shows that the one Container in the Pod has a memory request of 100 MiB and a memory limit of 200 MiB.

[fetch the metrics for the pod]
$ kubectl top pod memory-demo --namespace=mem-example
NAME                        CPU(cores)   MEMORY(bytes)
memory-demo                 <something>  162856960

● The output shows that the Pod is using about 162,900,000 bytes of memory, which is about 150 MiB.
● This is greater than the Pod's 100 MiB request, but within the Pod's 200 MiB limit.

[delete Pod]
$ kubectl delete pod memory-demo --namespace=mem-example

[create the 2nd Pod]
$ kubectl apply -f Pod_2.yaml --namespace=mem-example
$ kubectl apply -f https://k8s.io/examples/pods/resource/memory-request-limit-2.yaml --namespace=mem-example

[view detailed information about the Pod]
$ kubectl get pod memory-demo-2 --namespace=mem-example
NAME            READY     STATUS      RESTARTS   AGE
memory-demo-2   0/1       OOMKilled   1          24s

[view detailed information about the Pod]
$ kubectl get pod memory-demo-2 --output=yaml --namespace=mem-example
..........
..........
lastState:
   terminated:
     containerID: 65183c1877aaec2e8427bc95609cc52677a454b56fcb24340dbd22917c23b10f
     exitCode: 137
     finishedAt: 2017-06-20T20:52:19Z
     reason: OOMKilled
     startedAt: null
..........
..........

● The output shows that the Container was killed because it is out of memory (OOM).

[repeat to view detailed information about the Pod]
$ kubectl get pod memory-demo-2 --namespace=mem-example
NAME            READY     STATUS      RESTARTS   AGE
memory-demo-2   0/1       OOMKilled   1          37s
$ kubectl get pod memory-demo-2 --namespace=mem-example
NAME            READY     STATUS    RESTARTS   AGE
memory-demo-2   1/1       Running   2          40s

● The output shows that the Container is killed, restarted, killed again, restarted again.

[view detailed information about the Pod history]
$ kubectl describe pod memory-demo-2 --namespace=mem-example
..........
..........
... Normal  Created   Created container with id 66a3a20aa7980e61be4922780bf9d24d1a1d8b7395c09861225b0eba1b1f8511
... Warning BackOff   Back-off restarting failed container
..........
..........

● The output shows that the Container starts and fails repeatedly.

[view detailed information about your cluster's Nodes]
$ kubectl describe nodes
..........
..........
Warning OOMKilling Memory cgroup out of memory: Kill process 4481 (stress) score 1994 or sacrifice child
..........
..........

● The output includes a record of the Container being killed because of an out-of-memory condition.

[delete Pod]
$ kubectl delete pod memory-demo-2 --namespace=mem-example

[create the 3rd Pod]
$ kubectl apply -f Pod_3.yaml --namespace=mem-example
$ kubectl apply -f https://k8s.io/examples/pods/resource/memory-request-limit-3.yaml --namespace=mem-example

[view the Pod status]
$ kubectl get pod memory-demo-3 --namespace=mem-example
NAME            READY     STATUS    RESTARTS   AGE
memory-demo-3   0/1       Pending   0          25s

● The output shows that the Pod status is PENDING.
● The Pod is not scheduled to run on any Node, and it will remain in the PENDING state indefinitely.

[view detailed information about the Pod, including events]
$ kubectl describe pod memory-demo-3 --namespace=mem-example
..........
..........
Events:
  ...  Reason            Message
       ------            -------
  ...  FailedScheduling  No nodes are available that match all of the following predicates:: Insufficient memory (3).
..........
..........

● The output shows that the Container cannot be scheduled because of insufficient memory on the Nodes.

[delete Pod]
$ kubectl delete pod memory-demo-3 --namespace=mem-example

[delete Namespace]
$ kubectl delete namespace mem-example


[If you do not specify a memory limit]
The Container has no upper bound on the amount of memory it uses. 
The Container could use all of the memory available on the Node where it is running which in turn could invoke the OOM Killer.
Further, in case of an OOM Kill, a container with no resource limits will have a greater chance of being killed.
The Container is running in a namespace that has a default memory limit, and the Container is automatically assigned the default limit.
Cluster administrators can use a LimitRange to specify a default value for the memory limit.
